package org.his.utils;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AuthInterceptor implements HandlerInterceptor{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception{
        Object user = request.getSession().getAttribute(Common.LOGIN_USER);
        if (user == null){
            response.sendRedirect(request.getContextPath()+"/user/login");
            return  false;
        }
        return true;
    }
}
